<?php

import("ORG.Util.Function");
import("@.Org.OrderTool");
import("@.Org.Utils");


class OrderModel extends CommonModel{
	
	private $order_info		=	"ybr_order_info";
	private $admin_user		=	"ybr_admin_user";
	private $users			=	"ybr_users";
	
	/**
	 *  获取订单列表SQL
	 *  
	 */
	function get_sql_order_list(){
        /* 过滤信息 */
        $filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
        
        $filter['consignee'] = empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);	// 收货人
        $filter['email'] = empty($_REQUEST['email']) ? '' : trim($_REQUEST['email']);				// 邮箱
        $filter['address'] = empty($_REQUEST['address']) ? '' : trim($_REQUEST['address']);			// 地址
        $filter['zipcode'] = empty($_REQUEST['zipcode']) ? '' : trim($_REQUEST['zipcode']);			// 邮政编码
        $filter['tel'] = empty($_REQUEST['tel']) ? '' : trim($_REQUEST['tel']);						// 电话
        $filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);			// 手机号码
        $filter['country'] = empty($_REQUEST['country']) ? 0 : intval($_REQUEST['country']);		// 国家
        $filter['province'] = empty($_REQUEST['province']) ? 0 : intval($_REQUEST['province']);		// 省份
        $filter['city'] = empty($_REQUEST['city']) ? 0 : intval($_REQUEST['city']);					// 城市
        $filter['district'] = empty($_REQUEST['district']) ? 0 : intval($_REQUEST['district']);		// 地区
        $filter['shipping_id'] = empty($_REQUEST['shipping_id']) ? 0 : intval($_REQUEST['shipping_id']);				// 运送方式id
        $filter['pay_id'] = empty($_REQUEST['pay_id']) ? 0 : intval($_REQUEST['pay_id']);								// 
        $filter['order_status'] = isset($_REQUEST['order_status']) ? intval($_REQUEST['order_status']) : -1;			// 订单状态
        $filter['shipping_status'] = isset($_REQUEST['shipping_status']) ? intval($_REQUEST['shipping_status']) : -1;	// 运送状态
        $filter['pay_status'] = isset($_REQUEST['pay_status']) ? intval($_REQUEST['pay_status']) : -1;					// 付款状态
        $filter['user_id'] = empty($_REQUEST['user_id']) ? 0 : intval($_REQUEST['user_id']);							// 用户id
        $filter['user_name'] = empty($_REQUEST['user_name']) ? '' : trim($_REQUEST['user_name']);						// 用户名
        $filter['composite_status'] = isset($_REQUEST['composite_status']) ? intval($_REQUEST['composite_status']) : -1;// 
        $filter['group_buy_id'] = isset($_REQUEST['group_buy_id']) ? intval($_REQUEST['group_buy_id']) : 0;				// 团购id

        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'add_time' : trim($_REQUEST['sort_by']);						// 排序字段
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);

        $filter['start_time'] = empty($_REQUEST['start_time']) ? '' : (strpos($_REQUEST['start_time'], '-') > 0 ?  Utils::local_strtotime($_REQUEST['start_time']) : $_REQUEST['start_time']);	
        $filter['end_time'] = empty($_REQUEST['end_time']) ? '' : (strpos($_REQUEST['end_time'], '-') > 0 ?  Utils::local_strtotime($_REQUEST['end_time']) : $_REQUEST['end_time']);

        $where = 'WHERE 1 ';
        if ($filter['order_sn']){
            $where .= " AND o.order_sn LIKE '%" . Utils::mysql_like_quote($filter['order_sn']) . "%'";
        }
        if ($filter['consignee']){
            $where .= " AND o.consignee LIKE '%" . Utils::mysql_like_quote($filter['consignee']) . "%'";
        }
        if ($filter['email']){
            $where .= " AND o.email LIKE '%" . Utils::mysql_like_quote($filter['email']) . "%'";
        }
        if ($filter['address']){
            $where .= " AND o.address LIKE '%" . Utils::mysql_like_quote($filter['address']) . "%'";
        }
        if ($filter['zipcode']){
            $where .= " AND o.zipcode LIKE '%" . Utils::mysql_like_quote($filter['zipcode']) . "%'";
        }
        if ($filter['tel']){
            $where .= " AND o.tel LIKE '%" . Utils::mysql_like_quote($filter['tel']) . "%'";
        }
        if ($filter['mobile']){
            $where .= " AND o.mobile LIKE '%" . Utils::mysql_like_quote($filter['mobile']) . "%'";
        }
        if ($filter['country']){
            $where .= " AND o.country = '$filter[country]'";
        }
        if ($filter['province']){
            $where .= " AND o.province = '$filter[province]'";
        }
        if ($filter['city']){
            $where .= " AND o.city = '$filter[city]'";
        }
        if ($filter['district']){
            $where .= " AND o.district = '$filter[district]'";
        }
        if ($filter['shipping_id']){
            $where .= " AND o.shipping_id  = '$filter[shipping_id]'";
        }
        if ($filter['pay_id']){
            $where .= " AND o.pay_id  = '$filter[pay_id]'";
        }
        if ($filter['order_status'] != -1){
            $where .= " AND o.order_status  = '$filter[order_status]'";
        }
        if ($filter['shipping_status'] != -1){
            $where .= " AND o.shipping_status = '$filter[shipping_status]'";
        }
        if ($filter['pay_status'] != -1){
            $where .= " AND o.pay_status = '$filter[pay_status]'";
        }
        if ($filter['user_id']){
            $where .= " AND o.user_id = '$filter[user_id]'";
        }
        if ($filter['user_name']){
            $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['user_name']) . "%'";
        }
        if ($filter['start_time']){
            $where .= " AND o.add_time >= '$filter[start_time]'";
        }
        if ($filter['end_time']){
            $where .= " AND o.add_time <= '$filter[end_time]'";
        }

        //综合状态
        switch($filter['composite_status']){
            case CS_AWAIT_PAY :
                $where .= 	OrderTool::order_query_sql('await_pay');
                break;

            case CS_AWAIT_SHIP :
                $where .= OrderTool::order_query_sql('await_ship');
                break;

            case CS_FINISHED :
                $where .= OrderTool::order_query_sql('finished');
                break;

            case PS_PAYING :
                if ($filter['composite_status'] != -1)
                {
                    $where .= " AND o.pay_status = '$filter[composite_status]' ";
                }
                break;
            case OS_SHIPPED_PART :
                if ($filter['composite_status'] != -1)
                {
                    $where .= " AND o.shipping_status  = '$filter[composite_status]'-2 ";
                }
                break;
            default:
                if ($filter['composite_status'] != -1)
                {
                    $where .= " AND o.order_status = '$filter[composite_status]' ";
                }
        }

        /* 团购订单 */
        if ($filter['group_buy_id']){
            $where .= " AND o.extension_code = 'group_buy' AND o.extension_id = '$filter[group_buy_id]' ";
        }

        /* 如果管理员属于某个办事处，只列出这个办事处管辖的订单 */
        //$sql = "SELECT agency_id FROM " . $this->admin_user . " WHERE user_id = '$_SESSION[admin_id]'";
        $agency_id	=	M('admin_user')->where(" user_id = '1' ")->getField("agency_id");        
        if ($agency_id > 0){
            $where .= " AND o.agency_id = '$agency_id' ";
        }
        /* 查询 */
        $sql 	= 	"SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," .
                    "o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " .
                    "(" . order_amount_field('o.') . ") AS total_fee, " .
                    "IFNULL(u.user_name, '匿名用户') AS buyer ".
                	" FROM " . $this->order_info . " AS o " .
                	" LEFT JOIN " .$this->users. " AS u ON u.user_id=o.user_id ". $where .
                	" ORDER BY $filter[sort_by] $filter[sort_order] ";

        foreach (array('order_sn', 'consignee', 'email', 'address', 'zipcode', 'tel', 'user_name') AS $val){
            $filter[$val] = $filter[$val];
        }
 
        return $sql;
	}
	
	/**
	 * 取得订单信息
	 * @param   int     $order_id   订单id（如果order_id > 0 就按id查，否则按sn查）
	 * @param   string  $order_sn   订单号
	 * @return  array   订单信息（金额都有相应格式化的字段，前缀是formated_）
	 */
	function get_order_info($order_id, $order_sn = ''){
	    /* 计算订单各种费用之和的语句 */
	    $total_fee 	= 	" (goods_amount - discount + tax + shipping_fee + insure_fee + pay_fee + pack_fee + card_fee) AS total_fee ";
	    $order_id 	= 	intval($order_id);
	    if ($order_id > 0){
	        $sql 	= 	"SELECT *, " . $total_fee . " FROM " . 'ybr_order_info' .
	                	" WHERE order_id = '$order_id'";
	    }
	    else{
	        $sql 	= 	"SELECT *, " . $total_fee . "  FROM " . 'order_info' .
	                	" WHERE order_sn = '$order_sn'";
	    }
	    	    
	    $datas			=	M()->query($sql);
	    $order			=	$datas[0];
	
	    /* 格式化金额字段 */
	    if ($order){
	        $order['formated_goods_amount']   = price_format($order['goods_amount'], false);
	        $order['formated_discount']       = price_format($order['discount'], false);
	        $order['formated_tax']            = price_format($order['tax'], false);
	        $order['formated_shipping_fee']   = price_format($order['shipping_fee'], false);
	        $order['formated_insure_fee']     = price_format($order['insure_fee'], false);
	        $order['formated_pay_fee']        = price_format($order['pay_fee'], false);
	        $order['formated_pack_fee']       = price_format($order['pack_fee'], false);
	        $order['formated_card_fee']       = price_format($order['card_fee'], false);
	        $order['formated_total_fee']      = price_format($order['total_fee'], false);
	        $order['formated_money_paid']     = price_format($order['money_paid'], false);
	        $order['formated_bonus']          = price_format($order['bonus'], false);
	        $order['formated_integral_money'] = price_format($order['integral_money'], false);
	        $order['formated_surplus']        = price_format($order['surplus'], false);
	        $order['formated_order_amount']   = price_format(abs($order['order_amount']), false);
	        $order['formated_add_time']       = local_date("Y-m-d H:m:s", $order['add_time']);
	    }	
	    return $order;
	}
	

	/**
	 * 取得某订单商品总重量和总金额（对应 cart_weight_price）
	 * @param   int     $order_id   订单id
	 * @return  array   ('weight' => **, 'amount' => **, 'formated_weight' => **)
	 */
	function order_weight_price($order_id){
	    $sql 	= 	"SELECT SUM(g.goods_weight * o.goods_number) AS weight, " .
	                "SUM(o.goods_price * o.goods_number) AS amount ," .
	                "SUM(o.goods_number) AS number " .
	            	"FROM " . 'ybr_order_goods' . " AS o, " .
	                'ybr_goods' . " AS g " .
	            	"WHERE o.order_id = '$order_id' " .
	            	"AND o.goods_id = g.goods_id";
	
	    $datas 	= 	M()->query($sql);
	    $row	=	$datas[0];
	    $row['weight'] = floatval($row['weight']);
	    $row['amount'] = floatval($row['amount']);
	    $row['number'] = intval($row['number']);
	
	    /* 格式化重量 */
	    $row['formated_weight'] = formated_weight($row['weight']);
	
	    return $row;
	}
		
	/**
	 * 获得指定礼包的商品
	 *
	 * @access  public
	 * @param   integer $package_id
	 * @return  array
	 */
	function get_package_goods($package_id){
	    $sql 	= 	"SELECT pg.goods_id, g.goods_name, pg.goods_number, p.goods_attr, p.product_number, p.product_id
	            	FROM " . 'ybr_package_goods' . " AS pg
	                LEFT JOIN " . 'ybr_goods' . " AS g ON pg.goods_id = g.goods_id
	                LEFT JOIN " . 'ybr_products' . " AS p ON pg.product_id = p.product_id
	            	WHERE pg.package_id = '$package_id'";
	    if ($package_id == 0){
	        $sql .= " AND pg.admin_id = '$_SESSION[admin_id]'";
	    }
	    //$resource = $GLOBALS['db']->query($sql);
	    $datas	=	$this->query($sql);
	    
	    if (!$datas){
	        return array();
	    }
	
	    $row = array();
	
	    /* 生成结果数组 取存在货品的商品id 组合商品id与货品id */
	    $good_product_str = '';
	    foreach($datas as $row){
	    	if ($_row['product_id'] > 0){
	            /* 取存商品id */
	            $good_product_str .= ',' . $_row['goods_id'];	
	            /* 组合商品id与货品id */
	            $_row['g_p'] = $_row['goods_id'] . '_' . $_row['product_id'];
	        }
	        else{
	            /* 组合商品id与货品id */
	            $_row['g_p'] = $_row['goods_id'];
	        }	
	        //生成结果数组
	        $row[] = $_row;
	    }
	    
	    
	    
//	    while ($_row = $GLOBALS['db']->fetch_array($resource))
//	    {
//	        if ($_row['product_id'] > 0)
//	        {
//	            /* 取存商品id */
//	            $good_product_str .= ',' . $_row['goods_id'];
//	
//	            /* 组合商品id与货品id */
//	            $_row['g_p'] = $_row['goods_id'] . '_' . $_row['product_id'];
//	        }
//	        else
//	        {
//	            /* 组合商品id与货品id */
//	            $_row['g_p'] = $_row['goods_id'];
//	        }
//	
//	        //生成结果数组
//	        $row[] = $_row;
//	    }

	    $good_product_str 		= 	trim($good_product_str, ',');
	
	    /* 取商品属性 */
	    if ($good_product_str != ''){
	        $sql 				= 	"SELECT goods_attr_id, attr_value FROM " . 'ybr_goods_attr'. " WHERE goods_id IN ($good_product_str)";
	        $result_goods_attr 	= 	$this->query($sql);
	
	        $_goods_attr 		= 	array();
	        foreach ($result_goods_attr as $value){
	            $_goods_attr[$value['goods_attr_id']] = $value['attr_value'];
	        }
	    }
	
	    /* 过滤货品 */
	    $format[0] = '%s[%s]--[%d]';
	    $format[1] = '%s--[%d]';
	    foreach ($row as $key => $value){
	        if ($value['goods_attr'] != ''){
	            $goods_attr_array = explode('|', $value['goods_attr']);
	
	            $goods_attr = array();
	            foreach ($goods_attr_array as $_attr){
	                $goods_attr[] = $_goods_attr[$_attr];
	            }
	
	            $row[$key]['goods_name'] = sprintf($format[0], $value['goods_name'], implode('，', $goods_attr), $value['goods_number']);
	        }
	        else{
	            $row[$key]['goods_name'] = sprintf($format[1], $value['goods_name'], $value['goods_number']);
	        }
	    }
	
	    return $row;
	}
	

	/**
	 * 查询购物车（订单id为0）或订单中是否有实体商品
	 * @param   int     $order_id   订单id
	 * @param   int     $flow_type  购物流程类型
	 * @return  bool
	 */
	function exist_real_goods($order_id = 0, $flow_type = CART_GENERAL_GOODS){
		$CommonModel	=	new CommonModel();
	    if ($order_id <= 0){
	        $sql 	= 	"SELECT COUNT(*) FROM " . 'ybr_cart' .
		                " WHERE session_id = '" . SESS_ID . "' AND is_real = 1 " .
		                "AND rec_type = '$flow_type'";
	    }
	    else{
	    	$sql 	= 	"SELECT COUNT(*) FROM " . 'ybr_order_goods' .
	                	" WHERE order_id = '$order_id' AND is_real = 1";
	    }
	    return $CommonModel->getOne($sql) > 0;
	}
			
	
	/**
	 * 取得订单商品
	 * @param   array     $order  订单数组
	 * @return array
	 */
	function get_order_goods($order){
	    $goods_list 	= 	array();
	    $goods_attr 	= 	array();
	    $CommonModel	=	new CommonModel();
	    $sql 			= 	"SELECT o.*, g.suppliers_id AS suppliers_id,IF(o.product_id > 0, p.product_number, g.goods_number) AS storage, o.goods_attr, IFNULL(b.brand_name, '') AS brand_name, p.product_sn " .
	            			"FROM " . 'ybr_order_goods' . " AS o ".
	            			"LEFT JOIN " . 'ybr_products' . " AS p ON o.product_id = p.product_id " .
	            			"LEFT JOIN " . 'ybr_goods' . " AS g ON o.goods_id = g.goods_id " .
	            			"LEFT JOIN " . 'ybr_brand' . " AS b ON g.brand_id = b.brand_id " .
	            			"WHERE o.order_id = '$order[order_id]' ";
	    $res = $CommonModel->query($sql);
	    foreach($res as $row){
	    	// 虚拟商品支持
	        if ($row['is_real'] == 0){
	            /* 取得语言项 
	            $filename = ROOT_PATH . 'plugins/' . $row['extension_code'] . '/languages/common_' . $GLOBALS['_CFG']['lang'] . '.php';
	            if (file_exists($filename)){
	                include_once($filename);
	                if (!empty($GLOBALS['_LANG'][$row['extension_code'].'_link'])){
	                    $row['goods_name'] = $row['goods_name'] . sprintf($GLOBALS['_LANG'][$row['extension_code'].'_link'], $row['goods_id'], $order['order_sn']);
	                }
	            }
	            */
	        }	
	        $row['formated_subtotal']       = price_format($row['goods_price'] * $row['goods_number']);
	        $row['formated_goods_price']    = price_format($row['goods_price']);	
	        $goods_attr[] 					= explode(' ', trim($row['goods_attr'])); //将商品属性拆分为一个数组	
	        if ($row['extension_code'] == 'package_buy'){
	            $row['storage'] = '';
	            $row['brand_name'] = '';
	            $row['package_goods_list'] = get_package_goods_list($row['goods_id']);
	        }	
	        //处理货品id
	        $row['product_id'] = empty($row['product_id']) ? 0 : $row['product_id'];	
	        $goods_list[] = $row;
	    }    
	
	    $attr = array();
	    $arr  = array();
	    foreach ($goods_attr AS $index => $array_val){
	        foreach ($array_val AS $value){
	            $arr = explode(':', $value);//以 : 号将属性拆开
	            $attr[$index][] =  @array('name' => $arr[0], 'value' => $arr[1]);
	        }
	    }	
	    return array('goods_list' => $goods_list, 'attr' => $attr);
	}
	
	/**
	 * 删除订单所有相关单子
	 * @param   int     $order_id      订单 id
	 * @param   int     $action_array  操作列表 Array('delivery', 'back', ......)
	 * @return  int     1，成功；0，失败
	 */
	function del_delivery($order_id, $action_array){
	    $return_res = 0;
	
	    if (empty($order_id) || empty($action_array)){
	        return $return_res;
	    }	
	    $query_delivery = 1;
	    $query_back = 1;
	    if (in_array('delivery', $action_array)){
	        $sql = 'DELETE O, G FROM ' . 'ybr_delivery_order' . ' AS O, ' . 'ybr_delivery_goods' . ' AS G
	                WHERE O.order_id = \'' . $order_id . '\'
	                AND O.delivery_id = G.delivery_id';
	        $query_delivery = M()->query($sql);
	    }
	    if (in_array('back', $action_array)){
	        $sql = 'DELETE O, G
	                FROM ' . 'ybr_back_order' . ' AS O, ' . 'ybr_back_goods' . ' AS G
	                WHERE O.order_id = \'' . $order_id . '\'
	                AND O.back_id = G.back_id';
	        $query_back = M()->query($sql);
	    }	
	    if ($query_delivery && $query_back){
	        $return_res = 1;
	    }	
	    return $return_res;
	}
		

	/**
	 * 订单退款
	 * @param   array   $order          订单
	 * @param   int     $refund_type    退款方式 1 到帐户余额 2 到退款申请（先到余额，再申请提款） 3 不处理
	 * @param   string  $refund_note    退款说明
	 * @param   float   $refund_amount  退款金额（如果为0，取订单已付款金额）
	 * @return  bool
	 */
	function order_refund($order, $refund_type, $refund_note, $refund_amount = 0){
	    /* 检查参数 */
	    $user_id = $order['user_id'];
	    if ($user_id == 0 && $refund_type == 1){
	        die('anonymous, cannot return to account balance');
	    }
	    	    
	    $amount = $refund_amount > 0 ? $refund_amount : $order['money_paid'];
	    if ($amount <= 0){	    	
	        return true;
	    }
		/* 是否为三种退款方式中的一种 */
	    if (!in_array($refund_type, array(1, 2, 3))){
	        die('invalid params');
	    }
	
	    /* 备注信息 */
	    if ($refund_note){
	        $change_desc = $refund_note;
	    }
	    else{
	        $change_desc = sprintf(L('order_refund'), $order['order_sn']);
	    }
	
	    /* 处理退款 */
	    if (1 == $refund_type){
	        log_account_change($user_id, $amount, 0, 0, 0, $change_desc);
	        return true;
	    }
	    elseif (2 == $refund_type){
	        /* 如果非匿名，退回余额 */
	        if ($user_id > 0){
	            log_account_change($user_id, $amount, 0, 0, 0, $change_desc);
	        }
	
	        /* user_account 表增加提款申请记录 */
	        $account = array(
	            'user_id'      => $user_id,
	            'amount'       => (-1) * $amount,
	            'add_time'     => gmtime(),
	            'user_note'    => $refund_note,
	            'process_type' => SURPLUS_RETURN,
	            'admin_user'   => $_SESSION['admin_name'],
	            'admin_note'   => sprintf(L('order_refund'), $order['order_sn']),
	            'is_paid'      => 0
	        );
	        $this->autoExecute('user_account', $account, 'INSERT');	        
	        return true;
	    }
	    else{	    	
	        return true;
	    }
	}
	
	/**
	 *  获取退货单列表信息
	 *
	 * @access  public
	 * @param
	 *
	 * @return void
	 */
	function get_sql_back_list(){
			
        /* 过滤信息 */
        $filter['delivery_sn'] 	= 	empty($_REQUEST['delivery_sn']) ? '' : trim($_REQUEST['delivery_sn']);
        $filter['order_sn'] 	=	empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
        $filter['order_id'] 	= 	empty($_REQUEST['order_id']) ? 0 : intval($_REQUEST['order_id']);
        if ($aiax == 1 && !empty($_REQUEST['consignee'])){
            $_REQUEST['consignee'] 	= 	$_REQUEST['consignee'];
        }
        $filter['consignee'] 	= 	empty($_REQUEST['consignee']) ? '' : trim($_REQUEST['consignee']);

        $filter['sort_by'] 		= 	empty($_REQUEST['sort_by']) ? 'update_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] 	= 	empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);

        $where 					= 	'WHERE 1 ';
        if ($filter['order_sn']){
            $where .= " AND order_sn LIKE '%" . Utils::mysql_like_quote($filter['order_sn']) . "%'";
        }
        if ($filter['consignee']){
            $where .= " AND consignee LIKE '%" . Utils::mysql_like_quote($filter['consignee']) . "%'";
        }
        if ($filter['delivery_sn']){
            $where .= " AND delivery_sn LIKE '%" . Utils::mysql_like_quote($filter['delivery_sn']) . "%'";
        }

        /* 获取管理员信息 */
        $admin_info = admin_info();

        /* 如果管理员属于某个办事处，只列出这个办事处管辖的发货单 */
        if ($admin_info['agency_id'] > 0){
            $where .= " AND agency_id = '" . $admin_info['agency_id'] . "' ";
        }

        /* 如果管理员属于某个供货商，只列出这个供货商的发货单 */
        if ($admin_info['suppliers_id'] > 0){
            $where .= " AND suppliers_id = '" . $admin_info['suppliers_id'] . "' ";
        }

        /* 查询 */
        $sql = "SELECT back_id, delivery_sn, order_sn, order_id, add_time, action_user, consignee, country,
                       province, city, district, tel, status, update_time, email, return_time
                FROM " . "ybr_back_order" . "
                $where
                ORDER BY " . $filter['sort_by'] . " " . $filter['sort_order'];	
		return $sql;
	}
		
	
	
	
	
}